import { lazy } from 'react';
import { Navigate, useRoutes } from 'react-router-dom';
import Login from '../view/Login';
import lazyLoad from './lazyLoad';

/**
 *	TODO: 静态路由，需要改动态路由
 */
// import DemoRouter from './modules/demo';
// import UserRouter from './modules/user';

const rootRouter = [
  {
    path: '/login',
    element: <Login />,
    meta: {
      title: '登录页',
      key: 'login',
    },
  },
//   ...DemoRouter,
//   ...UserRouter,
//   {
//     path: '/error',
//     element: lazyLoad(lazy(() => import('@/components/UI/Error'))),
//     meta: {
//       title: '出错了～',
//       key: 'error',
//     },
//   },
  {
    path: '*',
    element: <Navigate to="/error" />,
  },
];

const Router = () => {
  const routes = useRoutes(rootRouter);
  return routes;
};

export default Router;
